package org.example.dao;

import org.example.entity.BlockchainRecord;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface BlockchainDao {

    // 查询所有区块链记录
    @Select("SELECT * FROM blockchain_record")
    List<BlockchainRecord> selectAllRecords();

    // 根据ID查询区块链记录
    @Select("SELECT * FROM blockchain_record WHERE id = #{id}")
    BlockchainRecord selectRecordById(Integer id);

    // 根据交易哈希查询区块链记录
    @Select("SELECT * FROM blockchain_record WHERE transaction_hash = #{transactionHash}")
    BlockchainRecord selectRecordByTransactionHash(String transactionHash);

    // 插入新的区块链记录
    @Insert("INSERT INTO blockchain_record (transaction_hash, data, timestamp) VALUES (#{transactionHash}, #{data}, #{timestamp})")
    void insertRecord(BlockchainRecord record);
}

